import request from '@/utils/request'
import { config } from '@/utils/requestconfig'

export function GetRole(params) {
  return request({
    baseURL: config.webapi,
    url: 'Role/GetRole',
    method: 'post',
    data: params
  })
}
// 新增
export function addRole(data) {
  return request({
    baseURL: config.webapi,
    url: 'Role/Add',
    method: 'post',
    data: data
  })
}
// 修改
export function editRole(data) {
  return request({
    baseURL: config.webapi,
    url: 'Role/Update',
    method: 'post',
    data: data
  })
}
// 删除
export function deleteRole(id) {
  return request({
    baseURL: config.webapi,
    url: 'Role/Delete',
    method: 'post',
    data: { id: id }
  })
}
// 查询某角色下的用户
export function loadRoleUser(data) {
  return request({
    baseURL: config.webapi,
    url: 'Role/LoadRoleUser',
    method: 'post',
    data: data
  })
}
// 保存某一角色下用户
export function saveRoleUser(data) {
  return request({
    baseURL: config.webapi,
    url: 'Role/SaveRoleUser',
    method: 'post',
    data: data
  })
}

export function getUnitRoles() {
  return request({
    baseURL: config.webapi,
    url: 'Role/GetUnitRoles',
    method: 'get'
  })
}

export function getUnitFlowRoles() {
  return request({
    baseURL: config.webapi,
    url: 'Role/GetUnitFlowRoles',
    method: 'get'
  })
}
// 获取指定角色的菜单ids
export function GetMenuIdsByRoleId(id) {
  return request({
    baseURL: config.webapi,
    url: 'Role/GetMenuIdsByRoleId',
    method: 'get',
    params: { roleId: id }
  })
}

